import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-21
 * Time:18:46
 */
@WebServlet("/hello")
public class HelloServlet extends HttpServlet {

    @Override               //此次请求http的请求内容,    请求此次需要返回的http响应内容
                            //当Tomcat收到一个合适的GET请求时,就会调用该该方法,并且Tomcat会解析此次的HTTP的请求
                            //因此,我们只需要根据请求,计算响应.Tomcat会自动将响应对象转换为符合Http协议的响应报文
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //该代码需要删除
        //super.doGet(req, resp);
        System.out.println("hello world");

        //返回给客户端
        resp.getWriter().write("hello world");


    }
}
